package com.applet.applet_shangcheng.dao;

import com.applet.applet_shangcheng.entity.TheProblem;
import com.applet.applet_shangcheng.entity.TheRules;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TheRulesMapper {

    @Insert({
            "insert into tb_the_rules (title,content,synopsis,image,status) values (#{title},#{content},#{synopsis},#{image},#{status})"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertTheRules(TheRules theRules);

    @Update({
            "update tb_the_rules set title=#{title},content=#{content},synopsis=#{synopsis},image=#{image},status=#{status} where id=#{id}"
    })
    int updateTheRules(TheRules theRules);

    @Update({
            "update tb_the_rules set status=#{status} where id=#{id}"
    })
    int updateStatus(@Param("id") int id,@Param("status") int status);

    @Delete({
            "delete from tb_the_rules where id =#{id}"
    })
    int deleteTheRules(@Param("id")int id);

    @Select({
            "select * from tb_the_rules where status =1"
    })
    List<TheRules> getTheRules();
    @Select({
            "select title,content,thereof_we,synopsis from tb_the_problem where synopsis =#{synopsis}"
    })
    TheProblem findTheProblem(@Param("synopsis") String synopsis);
    @Update({
            "update tb_the_problem set title=#{title},content=#{content},thereof_we=#{thereofWe} where synopsis =#{synopsis}"
    })
    int updateTheProblem(TheProblem theProblem);

    Page<TheRules> findAll(String queryString);

    @Select({
            "select * from tb_the_rules where id=#{id}"
    })
    TheRules findByTheRules(String id);

    Page<TheProblem> findAlls(String queryString);
}

